package gameobjects;

import java.awt.Graphics;
import abstracts.Task;
import resources.Sprite;
import tools.Bounds;
import interfaces.Visible;

public class ShrinkAnimation extends Task implements Visible {
    private final Bounds BOUNDS;
    private final Sprite SPRITE;
    private final double SPEED;
    private double scale;

    public ShrinkAnimation(Bounds bounds, Sprite sprite, double speed) {
        BOUNDS = bounds;
        SPRITE = sprite;
        SPEED = speed;
        scale = 1;
    }

    @Override
    public void draw(Graphics g) {
        SPRITE.drawAnchoredScaled(g, 0, BOUNDS, scale);
        scale -= SPEED;
    }

    @Override
    public double getDepth() {
        return BOUNDS.getMaxY();
    }

    @Override
    public boolean isDone() {
        return scale <= 0;
    }
}
